<template>
  <div class="app-container">
    <Find :OriginalFilter="{ static: true }" :formList="formList" @findClicked="findData" @Launchform="Launchform3" @clickNumber="clickNumber" />

    <div style="display: flex">
      <el-card style="margin-top: 10px; width: 15%" shadow="always" :body-style="{ padding: '5px' }">
        <h1>工种资料建档</h1>
        <Find
          :OriginalFilter="{ static: true }"
          :searchImg="false"
          style="width: 10%"
          :formList="formList1"
          @Launchform="Launchform"
          @findClicked="findData5"
        />
        <Table
          :isLoading="isLoading1"
          style="margin-top: 10px; width: 100%"
          :selection="true"
          :tableHeader="tableHeader"
          :tableData="JobDataFileInquiryTableDate"
          :TableHeight="65"
        />
      </el-card>

      <el-card style="margin-top: 10px; margin-left: 10px; width: 90%" shadow="always" :body-style="{ padding: '5px' }">
        <h1>基本工资变更</h1>
        <Find :OriginalFilter="{ static: true }" :searchImg="false" :formList="formList2" @findClicked="findData1" @Launchform="Launchform5" />
        <h1 style="margin-top: 15px">员工资料明细</h1>
        <Table
          @selectList="selection"
          :isLoading="isLoading"
          style="margin-top: 10px; width: 100%"
          :selection="true"
          :tableHeader="tableHeader1"
          :tableData="EmployeeDetailsParmsTableDate"
          :TableHeight="80"
        />
        <PageModule :PageData="{ total, buttonS: true }" @pageSizeChange="handleSizeChange" @pageChange="handleCurrentChange" />
      </el-card>
    </div>

    <el-dialog v-model="dialogVisible1" width="80%">
      <Find :OriginalFilter="{ static: true }" :searchImg="false" :formList="formList3" @Launchform="Launchform7" @findClicked="findData3" />
      <Table
        :isLoading="isLoading3"
        style="margin-top: 10px; width: 100%"
        :selection="true"
        :tableHeader="tableHeader3"
        :tableData="ChangeQueryTableDate"
        :TableHeight="80"
      />
      <PageModule :PageData="{ total: total1, buttonS: true }" @pageSizeChange="handleSizeChange1" @pageChange="handleCurrentChange1" />
    </el-dialog>

    <el-dialog v-model="dialogVisible2" width="80%">
      <Find :OriginalFilter="{ static: true }" :searchImg="false" :formList="formList5" @Launchform="Launchform8" @findClicked="findData7" />
      <Table
        :isLoading="isLoading5"
        style="margin-top: 10px; width: 50%"
        :selection="true"
        :tableHeader="tableHeader5"
        :tableData="JobChangeInquiryTableDate"
        :TableHeight="80"
      />
      <PageModule :PageData="{ total: total2, buttonS: true }" @pageSizeChange="handleSizeChange2" @pageChange="handleCurrentChange2" />
    </el-dialog>

    <el-dialog v-model="dialogVisible3" width="80%">
      <Find :OriginalFilter="{ static: true }" :searchImg="false" :formList="formList6" @Launchform="Launchform9" @findClicked="findData8" />
      <Tables
        :functionList="true"
        @modifTable1="modifTable1"
        @deleteRow="deleteRow"
        :updated="true"
        :deleteButton="true"
        :isLoading="isLoading6"
        style="margin-top: 30px; width: 50%"
        :selection="true"
        :tableHeader="tableHeader6"
        :tableData="TypeOfWorkFileInquiryMethodsTableDate"
        :TableHeight="80"
      />
      <PageModule :PageData="{ total: total3, buttonS: true }" @pageSizeChange="handleSizeChange3" @pageChange="handleCurrentChange3" />
    </el-dialog>
  </div>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import { GainDeptNmae } from '@/api/WarehouseDepartment/FactoryStorage/ConsumablesIn'

import JMessage from '@/utils/JMessage'
export default defineComponent({
  name: 'PayrollFileCreationThree'
})
</script>
<script lang="ts" setup>
import { i18n, Jzhcn } from '@/i18n'
import type { formListType } from '@/components/Find/index.vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { ref, onMounted } from 'vue'
import {
  EmployeeDetails,
  JobQuery,
  JobInquiry,
  JobDataFileInquiry,
  ChangeQuery,
  ChangeConfirmation,
  interposition,
  JobChangeInquiry,
  TypeOfWorkFileInquiry,
  WorkTypeFileInsertion,
  JobFileDeleted,
  TypeOfWorkFileModification
} from '@/api/GeneralFinanceDepartment/GeneralFinanceDepartment/FactoryLaborWage'

// 修改
const TypeOfWorkFileModificationMethods = async (row: any) => {
  try {
    const result = await TypeOfWorkFileModification(row)
    if (result.code === 200) {
      TypeOfWorkFileInquiryMethods()
      JMessage.success(result.message)
    } else {
      JMessage.error(result.message)
    }
  } catch (error) {
    JMessage.error('修改出错请重试')
  }
}

const modifTable1 = (row: any) => {
  row.calcType = row.calcType.selectValue
  delete row.workTypeSalary
  delete row.workTypeCategory
  delete row.value
  delete row.workType
  TypeOfWorkFileModificationMethods(row)
}

// 工种建档删除
const JobFileDeletedc = ref('')

const JobFileDeletedMethods = async () => {
  try {
    const result = await JobFileDeleted(JobFileDeletedc.value)
    if (result.code === 200) {
      TypeOfWorkFileInquiryMethods()
      JMessage.success(result.message)
    } else {
      JMessage.error(result.message)
    }
  } catch (error) {
    JMessage.error('删除错误请重试')
  }
}

const handleCloseMateriaLKlc5 = () => {
  ElMessageBox.confirm('确认要删除数据吗?')
    .then(async () => {
      JobFileDeletedMethods()
    })
    .catch(() => {})
}

const deleteRow = (row: any) => {
  JobFileDeletedc.value = row.row.workTypeSeq
  handleCloseMateriaLKlc5()
}

// 工资建档插入

const WorkTypeFileInsertionMethods = async () => {
  TypeOfWorkFileInquiryParms.value.workTypeSeq = ''
  try {
    const result = await WorkTypeFileInsertion(TypeOfWorkFileInquiryParms.value)
    if (result.code === 200) {
      TypeOfWorkFileInquiryMethods()
      EmployeeDetailsMethods()
      JMessage.success(result.message)
    } else {
      JMessage.error(result.message)
    }
  } catch (error) {
    JMessage.error('插入出错请重试')
  }
}

const findData8 = (row: string) => {
  if (row === '插入') {
    if (
      TypeOfWorkFileInquiryParms.value.calcType === '' ||
      TypeOfWorkFileInquiryParms.value.workType === '' ||
      TypeOfWorkFileInquiryParms.value.workTypeShort === ''
    ) {
      JMessage.warning('数据不完整')
    } else {
      WorkTypeFileInsertionMethods()
    }
  }

  if (row === '置空') {
    clearFormList5()
  }
}

const clearFormList5 = () => {
  formList6.value.forEach((item: any) => {
    if (item.type === 'input') {
      item.inputValue = ''
    }
    if (item.type === 'select') {
      item.selectValue = ''
    }
  })
}

// 工种建档查询
const TypeOfWorkFileInquiryParms = ref({
  calcType: '',
  pageNum: 1,
  pageSize: 40,
  workType: '',
  workTypeSeq: '',
  workTypeShort: ''
})

const Launchform9 = (row: any) => {
  TypeOfWorkFileInquiryParms.value.workTypeSeq = row[0].inputValue
  TypeOfWorkFileInquiryParms.value.workType = row[1].inputValue
  TypeOfWorkFileInquiryParms.value.workTypeShort = row[2].inputValue
  TypeOfWorkFileInquiryParms.value.calcType = row[3].selectValue
  TypeOfWorkFileInquiryMethods()
}

const isLoading6 = ref(true)

const TypeOfWorkFileInquiryMethodsTableDate = ref([])

const TypeOfWorkFileInquiryMethods = async () => {
  isLoading6.value = true
  try {
    const result = await TypeOfWorkFileInquiry(TypeOfWorkFileInquiryParms.value)
    TypeOfWorkFileInquiryMethodsTableDate.value = result.list.map((item: any) => {
      if (item.flag1 !== null || item.flag1 !== null) {
        item.backgroundColor2 = '#80E0C0'
      }
      item.calcType = {
        selectValue: item.calcType || '',
        options: [
          { value: '计时', label: '计时', item: '1' },
          { value: '计件', label: '计件', item: '2' }
        ]
      }
      return item
    })
    total3.value = result.total
    isLoading6.value = false
  } catch (error) {
    isLoading6.value = false
    JMessage.error('工种建档查询出错')
  }
}

const total3 = ref(0)

const handleSizeChange3 = (val: number) => {
  TypeOfWorkFileInquiryParms.value.pageSize = val
  TypeOfWorkFileInquiryMethods()
}

const handleCurrentChange3 = (val: number) => {
  TypeOfWorkFileInquiryParms.value.pageNum = val
  TypeOfWorkFileInquiryMethods()
}

// 工种建档
const dialogVisible3 = ref(false)

const formList6 = ref<any>([
  {
    type: 'input',
    inputPlaceholder: '编号',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '工种',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '简称',
    inputValue: ''
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '工资类型',
    selectLabel: '',
    selectOptions: [
      {
        optionKey: 1,
        optionValue: '计时',
        optionLabel: '计时'
      },
      {
        optionKey: 2,
        optionValue: '计件',
        optionLabel: '计件'
      }
    ]
  },
  {
    type: 'button',
    checkboxLabel: '插入'
  },
  {
    type: 'button',
    checkboxLabel: '置空',
    bgColor: '#1890FF'
  }
])

// 工种变更查询
const dialogVisible2 = ref(false)

const formList5 = ref<any>([
  {
    type: 'select',
    selectValue: '',
    selectP: '工种',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'date',
    dateLabel: '变更日期',
    dateValue: ''
  },
  {
    type: 'button',
    checkboxLabel: '置空',
    bgColor: '#1890FF'
  }
])

const findData7 = (row: any) => {
  if (row === '置空') {
    clearFormList3()
  }
}

const clearFormList3 = () => {
  formList5.value.forEach((item: any) => {
    if (item.type === 'date') {
      item.dateValue = ''
    }
    if (item.type === 'select') {
      item.selectValue = ''
    }
  })
}

const JobChangeInquiryParms = ref({
  inTime: '',
  outTime: '',
  pageNum: 1,
  pageSize: 40,
  workType: ''
})

const Launchform8 = (row: any) => {
  JobChangeInquiryParms.value.inTime = row[1].dateValue[0]
  JobChangeInquiryParms.value.outTime = row[1].dateValue[1]
  JobChangeInquiryParms.value.workType = row[0].selectValue
  JobChangeInquiryMethods()
}

const isLoading5 = ref(true)

const JobChangeInquiryTableDate = ref([])

const JobChangeInquiryMethods = async () => {
  isLoading5.value = true
  try {
    const result = await JobChangeInquiry(JobChangeInquiryParms.value)
    JobChangeInquiryTableDate.value = result.list
    total2.value = result.total
    isLoading5.value = false
  } catch (error) {
    JMessage.error('工种变更查询出错')
    isLoading5.value = false
  }
}

const total2 = ref(0)

const handleSizeChange2 = (val: number) => {
  JobChangeInquiryParms.value.pageSize = val
  JobChangeInquiryMethods()
}

const handleCurrentChange2 = (val: number) => {
  JobChangeInquiryParms.value.pageNum = val
  JobChangeInquiryMethods()
}

// 插入
const interpositionParms = ref<any>({
  workType: '',
  salary: ''
})

const findData5 = (row: any) => {
  if (row === '插入') {
    if (interpositionParms.value.workType === '' || interpositionParms.value.salary === '') {
      JMessage.warning('插入时工种或工资不可为空')
    } else {
      interpositionMethods()
    }
  }

  if (row === '工种变更查询') {
    JobChangeInquiryMethods()
    dialogVisible2.value = true
  }

  if (row === '工种建档') {
    TypeOfWorkFileInquiryMethods()
    dialogVisible3.value = true
  }

  if (row === '置空') {
    clearFormList8()
  }
}

const clearFormList8 = () => {
  formList1.value.forEach((item: any) => {
    if (item.type === 'input') {
      item.inputValue = ''
    }
    if (item.type === 'select') {
      item.selectValue = ''
    }
  })
}

const Launchform = (row: any) => {
  JobDataFileInquiryParms.value = encodeURIComponent(row[0].selectValue)
  JobDataFileInquiryMethods()

  interpositionParms.value.workType = row[0].selectValue
  interpositionParms.value.salary = row[1].inputValue
}

const interpositionMethods = async () => {
  try {
    const result = await interposition(interpositionParms.value)
    if (result.code === 200) {
      JobDataFileInquiryMethods()
      EmployeeDetailsMethods()
      JMessage.success(result.message)
    } else {
      JMessage.error(result.message)
    }
  } catch (error) {
    JMessage.error('插入出错')
  }
}

// 变更确认
const ChangeConfirmationParms = ref<any>({
  calcType: '',
  sysDate: '',
  workType: '',
  workTypeSalary: '',
  workerIdList: []
})

const Launchform5 = (row: any) => {
  ChangeConfirmationParms.value.workTypeSalary = Number(row[0].inputValue)
}

const selection = (row: any) => {
  ChangeConfirmationParms.value.workerIdList = row.map((item: any) => {
    return item.workerId
  })
}

const ChangeConfirmationMethods = async () => {
  try {
    const result = await ChangeConfirmation(ChangeConfirmationParms.value)
    if (result.code === 200) {
      EmployeeDetailsMethods()
      JMessage.success(result.message)
    } else {
      JMessage.error(result.message)
    }
  } catch (error) {
    JMessage.error('变更确认异常')
  }
}

const findData3 = (row: any) => {
  if (row === '置空') {
    clearFormList()
  }
}

const clearFormList = () => {
  formList3.value.forEach((item: any) => {
    if (item.type === 'input') {
      item.inputValue = ''
    }
    if (item.type === 'date') {
      item.dateValue = ''
    }
    if (item.type === 'select') {
      item.selectValue = ''
    }
  })
}

// 变更查询
const ChangeQueryParms = ref({
  bankCardId: '',
  bankCardName: '',
  bankCardUser: '',
  calcType: '',
  deptName: '',
  flag: '',
  idNo: '',
  inTime: '',
  name: '',
  outTime: '',
  pageNum: 1,
  pageSize: 40,
  position: '',
  status: '',
  workType: '',
  workerId: ''
})

const Launchform7 = (row: any) => {
  ChangeQueryParms.value.deptName = row[0].selectValue.split(' ')[0]
  ChangeQueryParms.value.name = row[1].inputValue
  ChangeQueryParms.value.workerId = row[2].inputValue
  ChangeQueryParms.value.idNo = row[3].inputValue
  ChangeQueryParms.value.position = row[4].selectValue.split(' ')[1]
  ChangeQueryParms.value.workType = row[5].selectValue
  ChangeQueryParms.value.calcType = row[6].selectValue

  ChangeQueryParms.value.inTime = row[7].dateValue[0]
  ChangeQueryParms.value.outTime = row[7].dateValue[1]
  ChangeQueryMethods()
}

const isLoading3 = ref(true)

const total1 = ref(0)

// 部门查询
const GainDeptNmaeMethids1 = async () => {
  let NewArray = <any>[]

  const result = await GainDeptNmae()

  NewArray = result.reduce((arr: any, item: any) => {
    if (item.deptName) {
      // 只添加非空的 typeName 和 typeNo
      arr.push(item.deptName + ' ' + item.deptNo)
    }
    return arr
  }, [])

  formList3.value[0].selectOptions = EvaluatesTheArrayReturnValue(NewArray)
}

const handleSizeChange1 = (val: number) => {
  ChangeQueryParms.value.pageSize = val
  ChangeQueryMethods()
}

const handleCurrentChange1 = (val: number) => {
  ChangeQueryParms.value.pageNum = val
  ChangeQueryMethods()
}

const ChangeQueryTableDate = ref([])

const ChangeQueryMethods = async () => {
  isLoading3.value = true
  try {
    const result = await ChangeQuery(ChangeQueryParms.value)
    ChangeQueryTableDate.value = result.list
    total1.value = result.total
    isLoading3.value = false
  } catch (error) {
    JMessage.error('变更查询出错')
    isLoading3.value = false
  }
}

const formList3 = ref<any>([
  {
    type: 'select',
    selectValue: '',
    selectP: '部门',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'input',
    inputPlaceholder: '姓名',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '工号',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '身份证号',
    inputValue: ''
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '职务',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '工种',
    selectLabel: '',
    selectOptions: []
  },

  {
    type: 'select',
    selectValue: '',
    selectP: '计件/计时',
    selectLabel: '',
    selectOptions: [
      {
        optionKey: 1,
        optionValue: '计时',
        optionLabel: '计时'
      },
      {
        optionKey: 2,
        optionValue: '计件',
        optionLabel: '计件'
      }
    ]
  },
  {
    type: 'date',
    dateLabel: '变更日期',
    dateValue: ''
  },
  {
    type: 'button',
    checkboxLabel: '置空',
    bgColor: '#1890FF'
  }
])

const dialogVisible1 = ref(false)

// 工种资料建档
const JobDataFileInquiryParms = ref('')

const isLoading1 = ref(false)

const findData1 = (count: string) => {
  if (count === '变更查询') {
    ChangeQueryMethods()
    GainDeptNmaeMethids1()
    dialogVisible1.value = true
  }
  if (count === '变更确认') {
    if (ChangeConfirmationParms.value.workerIdList.length === 0 || ChangeConfirmationParms.value.workTypeSalary === '') {
      JMessage.warning('基本工资或需要变更的数据不可为空')
    } else {
      ChangeConfirmationMethods()
    }
  }
}

const JobDataFileInquiryTableDate = ref([])

const JobDataFileInquiryMethods = async () => {
  isLoading1.value = true
  try {
    const result = await JobDataFileInquiry(JobDataFileInquiryParms.value)
    JobDataFileInquiryTableDate.value = result
    isLoading1.value = false
  } catch (error) {
    isLoading1.value = false
    JMessage.error('工种资料建档查询出错')
  }
}

// 职务查询
const JobInquiryMethods = async () => {
  try {
    let NewArray = <any>[]

    const result = await JobInquiry()

    NewArray = result.reduce((arr: any, item: any) => {
      if (item.positionSeq && item.position) {
        // 只添加非空的 typeName 和 typeNo
        arr.push(item.positionSeq + ' ' + item.position)
      }
      return arr
    }, [])

    formList.value[4].selectOptions = EvaluatesTheArrayReturnValue(NewArray)
    formList3.value[4].selectOptions = EvaluatesTheArrayReturnValue(NewArray)
  } catch (error) {
    JMessage.error('工种查询出错')
  }
}

// 工种查询
const JobQueryParms = ref({
  pageNum: 1,
  pageSize: 300,
  workType: ''
})

const JobQueryMethods = async () => {
  try {
    const result = await JobQuery(JobQueryParms.value)
    console.log(result)
    let NewArray = result.list.map((item: any) => {
      return item.workTypeShort
    })

    formList.value[3].selectOptions = EvaluatesTheArrayReturnValue(NewArray)
    formList1.value[0].selectOptions = EvaluatesTheArrayReturnValue(NewArray)
    formList3.value[5].selectOptions = EvaluatesTheArrayReturnValue(NewArray)
    formList5.value[0].selectOptions = EvaluatesTheArrayReturnValue(NewArray)
  } catch (error) {
    JMessage.error('工种查询出错')
  }
}

// 部门查询
const GainDeptNmaeMethids = async () => {
  let NewArray = <any>[]

  const result = await GainDeptNmae()

  NewArray = result.reduce((arr: any, item: any) => {
    if (item.deptName) {
      // 只添加非空的 typeName 和 typeNo
      arr.push(item.deptName)
    }
    return arr
  }, [])

  formList.value[0].selectOptions = EvaluatesTheArrayReturnValue(NewArray)
}

const EvaluatesTheArrayReturnValue = (ArrayList: any) => {
  return ArrayList.map((item: any, index: any) => {
    return {
      optionKey: index,
      optionValue: item,
      optionLabel: item
    }
  })
}

// 员工明细查询
const EmployeeDetailsParms = ref<any>({
  bankCardId: '',
  bankCardName: '',
  bankCardUser: '',
  calcType: '',
  deptName: '',
  flag: null,
  idNo: '',
  inTime: '',
  name: '',
  outTime: '',
  pageNum: 1,
  pageSize: 40,
  position: '',
  status: '',
  workType: '',
  workerId: ''
})

const clickNumber = (row: string) => {
  switch (row) {
    case '1': {
      EmployeeDetailsParms.value.flag = null
      break
    }
    case '2': {
      EmployeeDetailsParms.value.flag = 1
      break
    }
  }
  EmployeeDetailsMethods()
}

const Launchform3 = (row: any) => {
  EmployeeDetailsParms.value.deptName = row[0].selectValue
  EmployeeDetailsParms.value.workerId = row[1].inputValue
  EmployeeDetailsParms.value.name = row[2].inputValue
  EmployeeDetailsParms.value.workType = row[3].selectValue

  EmployeeDetailsParms.value.position = row[4].selectValue.split(' ')[1]
  EmployeeDetailsParms.value.bankCardName = row[5].inputValue
  EmployeeDetailsParms.value.bankCardUser = row[6].inputValue
  EmployeeDetailsParms.value.bankCardId = row[7].inputValue
  EmployeeDetailsParms.value.idNo = row[8].inputValue
  EmployeeDetailsParms.value.calcType = row[9].selectValue

  EmployeeDetailsParms.value.status = row[10].selectValue

  EmployeeDetailsParms.value.inTime = row[11].dateValue[0]
  EmployeeDetailsParms.value.outTime = row[11].dateValue[1]

  EmployeeDetailsMethods()
}

const isLoading = ref(true)

const EmployeeDetailsParmsTableDate = ref([])

const EmployeeDetailsMethods = async () => {
  isLoading.value = true
  try {
    if (EmployeeDetailsParms.value.status !== '') {
      EmployeeDetailsParms.value.status = EmployeeDetailsParms.value.status === '在职' ? 1 : 2
    }

    const result = await EmployeeDetails(EmployeeDetailsParms.value)
    EmployeeDetailsParmsTableDate.value = result.list.map((item: any) => {
      if (item.flag === 1) {
        item.backgroundColor2 = '#80E0C0'
      }

      return item
    })
    total.value = result.total
    isLoading.value = false
  } catch (error) {
    isLoading.value = false
    JMessage.error('员工资料明细查询出错')
  }
}

const total = ref(0)

const handleSizeChange = (val: number) => {
  EmployeeDetailsParms.value.pageSize = val
  EmployeeDetailsMethods()
}

const handleCurrentChange = (val: number) => {
  EmployeeDetailsParms.value.pageNum = val
  EmployeeDetailsMethods()
}

onMounted(() => {
  EmployeeDetailsMethods()

  GainDeptNmaeMethids()

  JobQueryMethods()

  JobInquiryMethods()

  JobDataFileInquiryMethods()
})

const formList = ref<any>([
  {
    type: 'select',
    selectValue: '',
    selectP: '部门',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'input',
    inputPlaceholder: '工号',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '姓名',
    inputValue: ''
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '工种',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '职务',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'input',
    inputPlaceholder: '开户行',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '开户名',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '银行卡号',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '身份证号',
    inputValue: ''
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '计件/计时',
    selectLabel: '',
    selectOptions: [
      {
        optionKey: 1,
        optionValue: '计时',
        optionLabel: '计时'
      },
      {
        optionKey: 2,
        optionValue: '计件',
        optionLabel: '计件'
      }
    ]
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '状态',
    selectLabel: '',
    selectOptions: [
      {
        optionKey: 1,
        optionValue: '在职',
        optionLabel: '在职'
      },
      {
        optionKey: 2,
        optionValue: '离职',
        optionLabel: '离职'
      }
    ]
  },
  {
    type: 'date',
    dateLabel: '进厂日期',
    dateValue: ''
  },
  {
    type: 'radio',
    checkboxLabel: '手动变更',
    checked: true,
    label: '2'
  },
  {
    type: 'radio',
    checkboxLabel: '全部',
    checked: false,
    label: '1'
  },
  {
    type: 'button',
    checkboxLabel: '置空',
    bgColor: '#1890FF'
  }
])

const formList1 = ref<any>([
  {
    type: 'select',
    selectValue: '',
    selectP: '工种',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'input',
    inputPlaceholder: '基本工资',
    inputValue: '',
    inputWidth: '128px'
  },
  {
    type: 'button',
    checkboxLabel: '插入'
  },
  {
    type: 'button',
    checkboxLabel: '置空',
    bgColor: '#1890FF'
  },
  {
    type: 'button',
    checkboxLabel: '工种变更查询'
  },
  {
    type: 'button',
    checkboxLabel: '工种建档'
  }
])

const formList2 = ref<any>([
  {
    type: 'input',
    inputPlaceholder: '基本工资',
    inputValue: ''
  },
  {
    type: 'button',
    checkboxLabel: '变更确认'
  },
  {
    type: 'button',
    checkboxLabel: '变更查询'
  }
])

const findData = (count: string) => {
  if (count === '置空') {
    clearFormList2()
  }
}

const clearFormList2 = () => {
  formList.value.forEach((item: any) => {
    if (item.type === 'input') {
      item.inputValue = ''
    }
    if (item.type === 'date') {
      item.dateValue = ''
    }
    if (item.type === 'select') {
      item.selectValue = ''
    }
    // Add other conditions for different form item types
  })
}

// 表格数据

const tableHeader = ref([
  {
    label: '工种',
    prop: 'workType'
  },
  {
    label: '基本工资',
    prop: 'workTypeSalary'
  }
])

const tableHeader1 = ref([
  {
    label: '部门',
    prop: 'deptName'
  },
  {
    label: '工号',
    prop: 'workerId'
  },
  {
    label: '姓名',
    prop: 'name'
  },
  {
    label: '性别',
    prop: 'sex'
  },
  {
    label: '身份证号码',
    prop: 'idNo'
  },
  {
    label: '职务',
    prop: 'position'
  },
  {
    label: '工种',
    prop: 'workType'
  },
  {
    label: '计件/计时',
    prop: 'calcType'
  },
  {
    label: '进厂日期',
    prop: 'dateIn'
  },
  {
    label: '离职日期',
    prop: 'delDate'
  },
  {
    label: '状态',
    prop: 'status'
  },
  {
    label: '基本工资',
    prop: 'basicSalary',
    backgroundColor2: true
  },
  {
    label: '开户名',
    prop: 'bankCardUser'
  },
  {
    label: '开户行',
    prop: 'bankCardName'
  },
  {
    label: '银行卡号',
    prop: 'bankCardId'
  }
])

const tableHeader3 = ref([
  {
    label: '异动日期',
    prop: 'sysDate',
    change: true
  },
  {
    label: '部门',
    prop: 'deptName',
    change: true
  },
  {
    label: '姓名',
    prop: 'name',
    change: true
  },
  {
    label: '性别',
    prop: 'sex',
    change: true
  },
  {
    label: '身份证号码',
    prop: 'idNo',
    change: true
  },
  {
    label: '职务',
    prop: 'position',
    change: true
  },
  {
    label: '工种',
    prop: 'workType',
    change: true
  },
  {
    label: '计件/计时',
    prop: 'calcType',
    change: true
  },
  {
    label: '进厂日期',
    prop: 'dateIn',
    change: true
  },
  {
    label: '变更前基本工资',
    prop: 'oldBasicSalary',
    change: true
  },
  {
    label: '变更后基本工资',
    prop: 'change',
    change: true
  }
])

const tableHeader5 = ref([
  {
    label: '变更日期',
    prop: 'sysDate'
  },
  {
    label: '工种',
    prop: 'workType'
  },
  {
    label: '变更前基本薪资',
    prop: 'salaryAlw'
  },
  {
    label: '变更后基本薪资',
    prop: 'newSalaryAlw'
  },
  {
    label: '操作员',
    prop: 'sysUser'
  }
])

const tableHeader6 = ref([
  {
    label: '编号',
    prop: 'workTypeSeq',
    type: 'input',
    change1: true
  },
  {
    label: '简称',
    prop: 'workTypeShort',
    type: 'input'
  },
  {
    label: '工种',
    prop: 'workType',
    type: 'input',
    change1: true,
    backgroundColor2: true
  },
  {
    label: '工资类型',
    prop: 'calcType',
    type: 'select'
  }
])
</script>

<style lang="less" scoped>
h1 {
  font-size: 14px;
  margin-bottom: 5px;
}
</style>
